/*
 * Copyright (c) 2000-2018, 达梦数据库有限公司.
 * All rights reserved.
 */
package dm

import (
	"bytes"
	"crypto/tls"
	"net"
	"strconv"
	"time"

	"gitee/zeqjone/gen/lib/dm/security"
)

const (
	Dm_build_1308 = 8192
	Dm_build_1309 = 2 * time.Second
)

type dm_build_1310 struct {
	dm_build_1311 *net.TCPConn
	dm_build_1312 *tls.Conn
	dm_build_1313 *Dm_build_978
	dm_build_1314 *DmConnection
	dm_build_1315 security.Cipher
	dm_build_1316 bool
	dm_build_1317 bool
	dm_build_1318 *security.DhKey

	dm_build_1319 bool
	dm_build_1320 string
	dm_build_1321 bool
}

func dm_build_1322(dm_build_1323 *DmConnection) (*dm_build_1310, error) {
	dm_build_1324, dm_build_1325 := dm_build_1327(dm_build_1323.dmConnector.host+":"+strconv.Itoa(int(dm_build_1323.dmConnector.port)), time.Duration(dm_build_1323.dmConnector.socketTimeout)*time.Second)
	if dm_build_1325 != nil {
		return nil, dm_build_1325
	}

	dm_build_1326 := dm_build_1310{}
	dm_build_1326.dm_build_1311 = dm_build_1324
	dm_build_1326.dm_build_1313 = Dm_build_981(Dm_build_6)
	dm_build_1326.dm_build_1314 = dm_build_1323
	dm_build_1326.dm_build_1316 = false
	dm_build_1326.dm_build_1317 = false
	dm_build_1326.dm_build_1319 = false
	dm_build_1326.dm_build_1320 = ""
	dm_build_1326.dm_build_1321 = false
	dm_build_1323.Access = &dm_build_1326

	return &dm_build_1326, nil
}

func dm_build_1327(dm_build_1328 string, dm_build_1329 time.Duration) (*net.TCPConn, error) {
	dm_build_1330, dm_build_1331 := net.DialTimeout("tcp", dm_build_1328, dm_build_1329)
	if dm_build_1331 != nil {
		return nil, ECGO_COMMUNITION_ERROR.addDetail("\tdial address: " + dm_build_1328).throw()
	}

	if tcpConn, ok := dm_build_1330.(*net.TCPConn); ok {

		tcpConn.SetKeepAlive(true)
		tcpConn.SetKeepAlivePeriod(Dm_build_1309)
		tcpConn.SetNoDelay(true)

		return tcpConn, nil
	}

	return nil, nil
}

func (dm_build_1333 *dm_build_1310) dm_build_1332(dm_build_1334 dm_build_126) bool {
	var dm_build_1335 = dm_build_1333.dm_build_1314.dmConnector.compress
	if dm_build_1334.dm_build_141() == Dm_build_33 || dm_build_1335 == Dm_build_82 {
		return false
	}

	if dm_build_1335 == Dm_build_80 {
		return true
	} else if dm_build_1335 == Dm_build_81 {
		return !dm_build_1333.dm_build_1314.Local && dm_build_1334.dm_build_139() > Dm_build_79
	}

	return false
}

func (dm_build_1337 *dm_build_1310) dm_build_1336(dm_build_1338 dm_build_126) bool {
	var dm_build_1339 = dm_build_1337.dm_build_1314.dmConnector.compress
	if dm_build_1338.dm_build_141() == Dm_build_33 || dm_build_1339 == Dm_build_82 {
		return false
	}

	if dm_build_1339 == Dm_build_80 {
		return true
	} else if dm_build_1339 == Dm_build_81 {
		return dm_build_1337.dm_build_1313.Dm_build_1241(Dm_build_41) == 1
	}

	return false
}

func (dm_build_1341 *dm_build_1310) dm_build_1340(dm_build_1342 dm_build_126) (err error) {
	defer func() {
		if p := recover(); p != nil {
			if _, ok := p.(string); ok {
				err = ECGO_COMMUNITION_ERROR.addDetail("\t" + p.(string)).throw()
			} else {
				panic(p)
			}
		}
	}()

	dm_build_1344 := dm_build_1342.dm_build_139()

	if dm_build_1344 > 0 {

		if dm_build_1341.dm_build_1332(dm_build_1342) {
			var retBytes, err = Compress(dm_build_1341.dm_build_1313, Dm_build_34, int(dm_build_1344), int(dm_build_1341.dm_build_1314.dmConnector.compressID))
			if err != nil {
				return err
			}

			dm_build_1341.dm_build_1313.Dm_build_992(Dm_build_34)

			dm_build_1341.dm_build_1313.Dm_build_1029(dm_build_1344)

			dm_build_1341.dm_build_1313.Dm_build_1057(retBytes)

			dm_build_1342.dm_build_140(int32(len(retBytes)) + ULINT_SIZE)

			dm_build_1341.dm_build_1313.Dm_build_1161(Dm_build_41, 1)
		}

		if dm_build_1341.dm_build_1317 {
			dm_build_1344 = dm_build_1342.dm_build_139()
			var retBytes = dm_build_1341.dm_build_1315.Encrypt(dm_build_1341.dm_build_1313.Dm_build_1268(Dm_build_34, int(dm_build_1344)), true)

			dm_build_1341.dm_build_1313.Dm_build_992(Dm_build_34)

			dm_build_1341.dm_build_1313.Dm_build_1057(retBytes)

			dm_build_1342.dm_build_140(int32(len(retBytes)))
		}
	}

	dm_build_1342.dm_build_135()
	if dm_build_1341.dm_build_1572(dm_build_1342) {
		if dm_build_1341.dm_build_1312 != nil {
			dm_build_1341.dm_build_1313.Dm_build_995(0)
			dm_build_1341.dm_build_1313.Dm_build_1014(dm_build_1341.dm_build_1312)
		}
	} else {
		dm_build_1341.dm_build_1313.Dm_build_995(0)
		dm_build_1341.dm_build_1313.Dm_build_1014(dm_build_1341.dm_build_1311)
	}
	return nil
}

func (dm_build_1346 *dm_build_1310) dm_build_1345(dm_build_1347 dm_build_126) (err error) {
	defer func() {
		if p := recover(); p != nil {
			if _, ok := p.(string); ok {
				err = ECGO_COMMUNITION_ERROR.addDetail("\t" + p.(string)).throw()
			} else {
				panic(p)
			}
		}
	}()

	dm_build_1349 := int32(0)
	if dm_build_1346.dm_build_1572(dm_build_1347) {
		if dm_build_1346.dm_build_1312 != nil {
			dm_build_1346.dm_build_1313.Dm_build_992(0)
			dm_build_1346.dm_build_1313.Dm_build_1008(dm_build_1346.dm_build_1312, Dm_build_34)
			dm_build_1349 = dm_build_1347.dm_build_139()
			if dm_build_1349 > 0 {
				dm_build_1346.dm_build_1313.Dm_build_1008(dm_build_1346.dm_build_1312, int(dm_build_1349))
			}
		}
	} else {

		dm_build_1346.dm_build_1313.Dm_build_992(0)
		dm_build_1346.dm_build_1313.Dm_build_1008(dm_build_1346.dm_build_1311, Dm_build_34)
		dm_build_1349 = dm_build_1347.dm_build_139()

		if dm_build_1349 > 0 {
			dm_build_1346.dm_build_1313.Dm_build_1008(dm_build_1346.dm_build_1311, int(dm_build_1349))
		}
	}

	dm_build_1347.dm_build_136()

	dm_build_1349 = dm_build_1347.dm_build_139()
	if dm_build_1349 <= 0 {
		return nil
	}

	if dm_build_1346.dm_build_1317 {
		ebytes := dm_build_1346.dm_build_1313.Dm_build_1268(Dm_build_34, int(dm_build_1349))
		bytes, err := dm_build_1346.dm_build_1315.Decrypt(ebytes, true)
		if err != nil {
			return err
		}
		dm_build_1346.dm_build_1313.Dm_build_992(Dm_build_34)
		dm_build_1346.dm_build_1313.Dm_build_1057(bytes)
		dm_build_1347.dm_build_140(int32(len(bytes)))
	}

	if dm_build_1346.dm_build_1336(dm_build_1347) {

		dm_build_1349 = dm_build_1347.dm_build_139()
		cbytes := dm_build_1346.dm_build_1313.Dm_build_1268(Dm_build_34+ULINT_SIZE, int(dm_build_1349-ULINT_SIZE))
		bytes, err := UnCompress(cbytes, int(dm_build_1346.dm_build_1314.dmConnector.compressID))
		if err != nil {
			return err
		}
		dm_build_1346.dm_build_1313.Dm_build_992(Dm_build_34)
		dm_build_1346.dm_build_1313.Dm_build_1057(bytes)
		dm_build_1347.dm_build_140(int32(len(bytes)))
	}
	return nil
}

func (dm_build_1351 *dm_build_1310) dm_build_1350(dm_build_1352 dm_build_126) (dm_build_1353 interface{}, dm_build_1354 error) {
	dm_build_1354 = dm_build_1352.dm_build_130(dm_build_1352)
	if dm_build_1354 != nil {
		return nil, dm_build_1354
	}

	dm_build_1354 = dm_build_1351.dm_build_1340(dm_build_1352)
	if dm_build_1354 != nil {
		return nil, dm_build_1354
	}

	dm_build_1354 = dm_build_1351.dm_build_1345(dm_build_1352)
	if dm_build_1354 != nil {
		return nil, dm_build_1354
	}

	return dm_build_1352.dm_build_134(dm_build_1352)
}

func (dm_build_1356 *dm_build_1310) dm_build_1355() (*dm_build_563, error) {

	Dm_build_1357 := dm_build_569(dm_build_1356)
	_, dm_build_1358 := dm_build_1356.dm_build_1350(Dm_build_1357)
	if dm_build_1358 != nil {
		return nil, dm_build_1358
	}

	return Dm_build_1357, nil
}

func (dm_build_1360 *dm_build_1310) dm_build_1359() error {

	dm_build_1361 := dm_build_431(dm_build_1360)
	_, dm_build_1362 := dm_build_1360.dm_build_1350(dm_build_1361)
	if dm_build_1362 != nil {
		return dm_build_1362
	}

	return nil
}

func (dm_build_1364 *dm_build_1310) dm_build_1363() error {

	var dm_build_1365 *dm_build_563
	var err error
	if dm_build_1365, err = dm_build_1364.dm_build_1355(); err != nil {
		return err
	}

	if dm_build_1364.dm_build_1314.sslEncrypt == 2 {
		if err = dm_build_1364.dm_build_1568(false); err != nil {
			return ECGO_INIT_SSL_FAILED.addDetail("\n" + err.Error()).throw()
		}
	} else if dm_build_1364.dm_build_1314.sslEncrypt == 1 {
		if err = dm_build_1364.dm_build_1568(true); err != nil {
			return ECGO_INIT_SSL_FAILED.addDetail("\n" + err.Error()).throw()
		}
	}

	if dm_build_1364.dm_build_1317 || dm_build_1364.dm_build_1316 {
		k, err := dm_build_1364.dm_build_1558()
		if err != nil {
			return err
		}
		sessionKey := security.ComputeSessionKey(k, dm_build_1365.Dm_build_567)
		encryptType := dm_build_1365.dm_build_565
		hashType := int(dm_build_1365.Dm_build_566)
		if encryptType == -1 {
			encryptType = security.DES_CFB
		}
		if hashType == -1 {
			hashType = security.MD5
		}
		err = dm_build_1364.dm_build_1561(encryptType, sessionKey, dm_build_1364.dm_build_1314.dmConnector.cipherPath, hashType)
		if err != nil {
			return err
		}
	}

	if err := dm_build_1364.dm_build_1359(); err != nil {
		return err
	}
	return nil
}

func (dm_build_1368 *dm_build_1310) Dm_build_1367(dm_build_1369 *DmStatement) error {
	dm_build_1370 := dm_build_592(dm_build_1368, dm_build_1369)
	_, dm_build_1371 := dm_build_1368.dm_build_1350(dm_build_1370)
	if dm_build_1371 != nil {
		return dm_build_1371
	}

	return nil
}

func (dm_build_1373 *dm_build_1310) Dm_build_1372(dm_build_1374 int32) error {
	dm_build_1375 := dm_build_602(dm_build_1373, dm_build_1374)
	_, dm_build_1376 := dm_build_1373.dm_build_1350(dm_build_1375)
	if dm_build_1376 != nil {
		return dm_build_1376
	}

	return nil
}

func (dm_build_1378 *dm_build_1310) Dm_build_1377(dm_build_1379 *DmStatement, dm_build_1380 bool, dm_build_1381 int16) (*execRetInfo, error) {
	dm_build_1382 := dm_build_469(dm_build_1378, dm_build_1379, dm_build_1380, dm_build_1381)
	dm_build_1383, dm_build_1384 := dm_build_1378.dm_build_1350(dm_build_1382)
	if dm_build_1384 != nil {
		return nil, dm_build_1384
	}
	return dm_build_1383.(*execRetInfo), nil
}

func (dm_build_1386 *dm_build_1310) Dm_build_1385(dm_build_1387 *DmStatement, dm_build_1388 int16) (*execRetInfo, error) {
	return dm_build_1386.Dm_build_1377(dm_build_1387, false, Dm_build_86)
}

func (dm_build_1390 *dm_build_1310) Dm_build_1389(dm_build_1391 *DmStatement, dm_build_1392 []OptParameter) (*execRetInfo, error) {
	dm_build_1393, dm_build_1394 := dm_build_1390.dm_build_1350(dm_build_228(dm_build_1390, dm_build_1391, dm_build_1392))
	if dm_build_1394 != nil {
		return nil, dm_build_1394
	}

	return dm_build_1393.(*execRetInfo), nil
}

func (dm_build_1396 *dm_build_1310) Dm_build_1395(dm_build_1397 *DmStatement, dm_build_1398 int16) (*execRetInfo, error) {
	return dm_build_1396.Dm_build_1377(dm_build_1397, true, dm_build_1398)
}

func (dm_build_1400 *dm_build_1310) Dm_build_1399(dm_build_1401 *DmStatement, dm_build_1402 [][]interface{}) (*execRetInfo, error) {
	dm_build_1403 := dm_build_251(dm_build_1400, dm_build_1401, dm_build_1402)
	dm_build_1404, dm_build_1405 := dm_build_1400.dm_build_1350(dm_build_1403)
	if dm_build_1405 != nil {
		return nil, dm_build_1405
	}
	return dm_build_1404.(*execRetInfo), nil
}

func (dm_build_1407 *dm_build_1310) Dm_build_1406(dm_build_1408 *DmStatement, dm_build_1409 [][]interface{}, dm_build_1410 bool) (*execRetInfo, error) {
	var dm_build_1411, dm_build_1412 = 0, 0
	var dm_build_1413 = len(dm_build_1409)
	var dm_build_1414 [][]interface{}
	var dm_build_1415 = NewExceInfo()
	dm_build_1415.updateCounts = make([]int64, dm_build_1413)
	var dm_build_1416 = false
	for dm_build_1411 < dm_build_1413 {
		for dm_build_1412 = dm_build_1411; dm_build_1412 < dm_build_1413; dm_build_1412++ {
			paramData := dm_build_1409[dm_build_1412]
			bindData := make([]interface{}, dm_build_1408.paramCount)
			dm_build_1416 = false
			for icol := 0; icol < int(dm_build_1408.paramCount); icol++ {
				if dm_build_1408.params[icol].ioType == IO_TYPE_OUT {
					continue
				}
				if dm_build_1407.dm_build_1541(bindData, paramData, icol) {
					dm_build_1416 = true
					break
				}
			}

			if dm_build_1416 {
				break
			}
			dm_build_1414 = append(dm_build_1414, bindData)
		}

		if dm_build_1412 != dm_build_1411 {
			tmpExecInfo, err := dm_build_1407.Dm_build_1399(dm_build_1408, dm_build_1414)
			if err != nil {
				return nil, err
			}
			dm_build_1414 = dm_build_1414[0:0]
			dm_build_1415.union(tmpExecInfo, dm_build_1411, dm_build_1412-dm_build_1411)
		}

		if dm_build_1412 < dm_build_1413 {
			tmpExecInfo, err := dm_build_1407.Dm_build_1417(dm_build_1408, dm_build_1409[dm_build_1412], dm_build_1410)
			if err != nil {
				return nil, err
			}

			dm_build_1410 = true
			dm_build_1415.union(tmpExecInfo, dm_build_1412, 1)
		}

		dm_build_1411 = dm_build_1412 + 1
	}
	for _, i := range dm_build_1415.updateCounts {
		if i > 0 {
			dm_build_1415.updateCount += i
		}
	}
	return dm_build_1415, nil
}

func (dm_build_1418 *dm_build_1310) Dm_build_1417(dm_build_1419 *DmStatement, dm_build_1420 []interface{}, dm_build_1421 bool) (*execRetInfo, error) {

	var dm_build_1422 = make([]interface{}, dm_build_1419.paramCount)
	for icol := 0; icol < int(dm_build_1419.paramCount); icol++ {
		if dm_build_1419.params[icol].ioType == IO_TYPE_OUT {
			continue
		}
		if dm_build_1418.dm_build_1541(dm_build_1422, dm_build_1420, icol) {

			if !dm_build_1421 {
				preExecute := dm_build_459(dm_build_1418, dm_build_1419, dm_build_1419.params)
				dm_build_1418.dm_build_1350(preExecute)
				dm_build_1421 = true
			}

			dm_build_1418.dm_build_1547(dm_build_1419, dm_build_1419.params[icol], icol, dm_build_1420[icol].(iOffRowBinder))
			dm_build_1422[icol] = ParamDataEnum_OFF_ROW
		}
	}

	var dm_build_1423 = make([][]interface{}, 1, 1)
	dm_build_1423[0] = dm_build_1422

	dm_build_1424 := dm_build_251(dm_build_1418, dm_build_1419, dm_build_1423)
	dm_build_1425, dm_build_1426 := dm_build_1418.dm_build_1350(dm_build_1424)
	if dm_build_1426 != nil {
		return nil, dm_build_1426
	}
	return dm_build_1425.(*execRetInfo), nil
}

func (dm_build_1428 *dm_build_1310) Dm_build_1427(dm_build_1429 *DmStatement, dm_build_1430 int16) (*execRetInfo, error) {
	dm_build_1431 := dm_build_446(dm_build_1428, dm_build_1429, dm_build_1430)

	dm_build_1432, dm_build_1433 := dm_build_1428.dm_build_1350(dm_build_1431)
	if dm_build_1433 != nil {
		return nil, dm_build_1433
	}
	return dm_build_1432.(*execRetInfo), nil
}

func (dm_build_1435 *dm_build_1310) Dm_build_1434(dm_build_1436 *innerRows, dm_build_1437 int64) (*execRetInfo, error) {
	dm_build_1438 := dm_build_351(dm_build_1435, dm_build_1436, dm_build_1437, INT64_MAX)
	dm_build_1439, dm_build_1440 := dm_build_1435.dm_build_1350(dm_build_1438)
	if dm_build_1440 != nil {
		return nil, dm_build_1440
	}
	return dm_build_1439.(*execRetInfo), nil
}

func (dm_build_1442 *dm_build_1310) Commit() error {
	dm_build_1443 := dm_build_214(dm_build_1442)
	_, dm_build_1444 := dm_build_1442.dm_build_1350(dm_build_1443)
	if dm_build_1444 != nil {
		return dm_build_1444
	}

	return nil
}

func (dm_build_1446 *dm_build_1310) Rollback() error {
	dm_build_1447 := dm_build_507(dm_build_1446)
	_, dm_build_1448 := dm_build_1446.dm_build_1350(dm_build_1447)
	if dm_build_1448 != nil {
		return dm_build_1448
	}

	return nil
}

func (dm_build_1450 *dm_build_1310) Dm_build_1449(dm_build_1451 *DmConnection) error {
	dm_build_1452 := dm_build_512(dm_build_1450, dm_build_1451.IsoLevel)
	_, dm_build_1453 := dm_build_1450.dm_build_1350(dm_build_1452)
	if dm_build_1453 != nil {
		return dm_build_1453
	}

	return nil
}

func (dm_build_1455 *dm_build_1310) Dm_build_1454(dm_build_1456 *DmStatement, dm_build_1457 string) error {
	dm_build_1458 := dm_build_219(dm_build_1455, dm_build_1456, dm_build_1457)
	_, dm_build_1459 := dm_build_1455.dm_build_1350(dm_build_1458)
	if dm_build_1459 != nil {
		return dm_build_1459
	}

	return nil
}

func (dm_build_1461 *dm_build_1310) Dm_build_1460(dm_build_1462 []uint32) ([]int64, error) {
	dm_build_1463 := dm_build_610(dm_build_1461, dm_build_1462)
	dm_build_1464, dm_build_1465 := dm_build_1461.dm_build_1350(dm_build_1463)
	if dm_build_1465 != nil {
		return nil, dm_build_1465
	}
	return dm_build_1464.([]int64), nil
}

func (dm_build_1467 *dm_build_1310) Close() error {
	if dm_build_1467.dm_build_1321 {
		return nil
	}

	dm_build_1468 := dm_build_1467.dm_build_1311.Close()
	if dm_build_1468 != nil {
		return dm_build_1468
	}

	dm_build_1467.dm_build_1314 = nil
	dm_build_1467.dm_build_1321 = true
	return nil
}

func (dm_build_1470 *dm_build_1310) dm_build_1469(dm_build_1471 *lob) (int64, error) {
	dm_build_1472 := dm_build_382(dm_build_1470, dm_build_1471)
	dm_build_1473, dm_build_1474 := dm_build_1470.dm_build_1350(dm_build_1472)
	if dm_build_1474 != nil {
		return 0, dm_build_1474
	}
	return dm_build_1473.(int64), nil
}

func (dm_build_1476 *dm_build_1310) dm_build_1475(dm_build_1477 *lob, dm_build_1478 int32, dm_build_1479 int32) ([]byte, error) {
	dm_build_1480 := dm_build_369(dm_build_1476, dm_build_1477, int(dm_build_1478), int(dm_build_1479))
	dm_build_1481, dm_build_1482 := dm_build_1476.dm_build_1350(dm_build_1480)
	if dm_build_1482 != nil {
		return nil, dm_build_1482
	}
	return dm_build_1481.([]byte), nil
}

func (dm_build_1484 *dm_build_1310) dm_build_1483(dm_build_1485 *DmBlob, dm_build_1486 int32, dm_build_1487 int32) ([]byte, error) {
	var dm_build_1488 = make([]byte, dm_build_1487)
	var dm_build_1489 int32 = 0
	var dm_build_1490 int32 = 0
	var dm_build_1491 []byte
	var dm_build_1492 error
	for dm_build_1489 < dm_build_1487 {
		dm_build_1490 = dm_build_1487 - dm_build_1489
		if dm_build_1490 > Dm_build_119 {
			dm_build_1490 = Dm_build_119
		}
		dm_build_1491, dm_build_1492 = dm_build_1484.dm_build_1475(&dm_build_1485.lob, dm_build_1486, dm_build_1490)
		if dm_build_1492 != nil {
			return nil, dm_build_1492
		}
		if dm_build_1491 == nil || len(dm_build_1491) == 0 {
			break
		}
		Dm_build_621.Dm_build_677(dm_build_1488, int(dm_build_1489), dm_build_1491, 0, len(dm_build_1491))
		dm_build_1489 += int32(len(dm_build_1491))
		dm_build_1486 += int32(len(dm_build_1491))
		if dm_build_1485.readOver {
			break
		}
	}
	return dm_build_1488, nil
}

func (dm_build_1494 *dm_build_1310) dm_build_1493(dm_build_1495 *DmClob, dm_build_1496 int32, dm_build_1497 int32) (string, error) {
	var dm_build_1498 bytes.Buffer
	var dm_build_1499 int32 = 0
	var dm_build_1500 int32 = 0
	var dm_build_1501 []byte
	var dm_build_1502 string
	var dm_build_1503 error
	for dm_build_1499 < dm_build_1497 {
		dm_build_1500 = dm_build_1497 - dm_build_1499
		if dm_build_1500 > Dm_build_119/2 {
			dm_build_1500 = Dm_build_119 / 2
		}
		dm_build_1501, dm_build_1503 = dm_build_1494.dm_build_1475(&dm_build_1495.lob, dm_build_1496, dm_build_1500)
		if dm_build_1503 != nil {
			return "", dm_build_1503
		}
		if dm_build_1501 == nil || len(dm_build_1501) == 0 {
			break
		}
		dm_build_1502 = Dm_build_621.Dm_build_778(dm_build_1501, 0, len(dm_build_1501), dm_build_1495.serverEncoding, dm_build_1494.dm_build_1314)

		dm_build_1498.WriteString(dm_build_1502)
		dm_build_1499 += int32(len(dm_build_1502))
		dm_build_1496 += int32(len(dm_build_1502))
		if dm_build_1495.readOver {
			break
		}
	}
	return dm_build_1498.String(), nil
}

func (dm_build_1505 *dm_build_1310) dm_build_1504(dm_build_1506 *DmClob, dm_build_1507 int, dm_build_1508 string, dm_build_1509 string) (int, error) {
	var dm_build_1510 = Dm_build_621.Dm_build_834(dm_build_1508, dm_build_1509, dm_build_1505.dm_build_1314)
	var dm_build_1511 = 0
	var dm_build_1512 = len(dm_build_1510)
	var dm_build_1513 = 0
	var dm_build_1514 = 0
	var dm_build_1515 = 0
	var dm_build_1516 = dm_build_1512/Dm_build_118 + 1
	var dm_build_1517 byte = 0
	var dm_build_1518 byte = 0x01
	var dm_build_1519 byte = 0x02
	for i := 0; i < dm_build_1516; i++ {
		dm_build_1517 = 0
		if i == 0 {
			dm_build_1517 |= dm_build_1518
		}
		if i == dm_build_1516-1 {
			dm_build_1517 |= dm_build_1519
		}
		dm_build_1515 = dm_build_1512 - dm_build_1514
		if dm_build_1515 > Dm_build_118 {
			dm_build_1515 = Dm_build_118
		}

		setLobData := dm_build_526(dm_build_1505, &dm_build_1506.lob, dm_build_1517, dm_build_1507, dm_build_1510, dm_build_1511, dm_build_1515)
		ret, err := dm_build_1505.dm_build_1350(setLobData)
		if err != nil {
			return 0, err
		}
		tmp := ret.(int32)
		if err != nil {
			return -1, err
		}
		if tmp <= 0 {
			return dm_build_1513, nil
		} else {
			dm_build_1507 += int(tmp)
			dm_build_1513 += int(tmp)
			dm_build_1514 += dm_build_1515
			dm_build_1511 += dm_build_1515
		}
	}
	return dm_build_1513, nil
}

func (dm_build_1521 *dm_build_1310) dm_build_1520(dm_build_1522 *DmBlob, dm_build_1523 int, dm_build_1524 []byte) (int, error) {
	var dm_build_1525 = 0
	var dm_build_1526 = len(dm_build_1524)
	var dm_build_1527 = 0
	var dm_build_1528 = 0
	var dm_build_1529 = 0
	var dm_build_1530 = dm_build_1526/Dm_build_118 + 1
	var dm_build_1531 byte = 0
	var dm_build_1532 byte = 0x01
	var dm_build_1533 byte = 0x02
	for i := 0; i < dm_build_1530; i++ {
		dm_build_1531 = 0
		if i == 0 {
			dm_build_1531 |= dm_build_1532
		}
		if i == dm_build_1530-1 {
			dm_build_1531 |= dm_build_1533
		}
		dm_build_1529 = dm_build_1526 - dm_build_1528
		if dm_build_1529 > Dm_build_118 {
			dm_build_1529 = Dm_build_118
		}

		setLobData := dm_build_526(dm_build_1521, &dm_build_1522.lob, dm_build_1531, dm_build_1523, dm_build_1524, dm_build_1525, dm_build_1529)
		ret, err := dm_build_1521.dm_build_1350(setLobData)
		if err != nil {
			return 0, err
		}
		tmp := ret.(int32)
		if tmp <= 0 {
			return dm_build_1527, nil
		} else {
			dm_build_1523 += int(tmp)
			dm_build_1527 += int(tmp)
			dm_build_1528 += dm_build_1529
			dm_build_1525 += dm_build_1529
		}
	}
	return dm_build_1527, nil
}

func (dm_build_1535 *dm_build_1310) dm_build_1534(dm_build_1536 *lob, dm_build_1537 int) (int64, error) {
	dm_build_1538 := dm_build_393(dm_build_1535, dm_build_1536, dm_build_1537)
	dm_build_1539, dm_build_1540 := dm_build_1535.dm_build_1350(dm_build_1538)
	if dm_build_1540 != nil {
		return dm_build_1536.length, dm_build_1540
	}
	return dm_build_1539.(int64), nil
}

func (dm_build_1542 *dm_build_1310) dm_build_1541(dm_build_1543 []interface{}, dm_build_1544 []interface{}, dm_build_1545 int) bool {
	var dm_build_1546 = false
	if dm_build_1545 >= len(dm_build_1544) || dm_build_1544[dm_build_1545] == nil {
		dm_build_1543[dm_build_1545] = ParamDataEnum_Null
	} else if binder, ok := dm_build_1544[dm_build_1545].(iOffRowBinder); ok {
		dm_build_1546 = true
		dm_build_1543[dm_build_1545] = ParamDataEnum_OFF_ROW
		var lob lob
		if l, ok := binder.getObj().(DmBlob); ok {
			lob = l.lob
		} else if l, ok := binder.getObj().(DmClob); ok {
			lob = l.lob
		}
		if &lob != nil && lob.canOptimized(dm_build_1542.dm_build_1314) {
			dm_build_1543[dm_build_1545] = &lobCtl{lob.buildCtlData()}
			dm_build_1546 = false
		}
	} else {
		dm_build_1543[dm_build_1545] = dm_build_1544[dm_build_1545]
	}
	return dm_build_1546
}

func (dm_build_1548 *dm_build_1310) dm_build_1547(dm_build_1549 *DmStatement, dm_build_1550 parameter, dm_build_1551 int, dm_build_1552 iOffRowBinder) error {
	var dm_build_1553 = Dm_build_904()
	dm_build_1552.read(dm_build_1553)
	var dm_build_1554 = 0
	for !dm_build_1552.isReadOver() || dm_build_1553.Dm_build_905() > 0 {
		if !dm_build_1552.isReadOver() && dm_build_1553.Dm_build_905() < Dm_build_118 {
			dm_build_1552.read(dm_build_1553)
		}
		if dm_build_1553.Dm_build_905() > Dm_build_118 {
			dm_build_1554 = Dm_build_118
		} else {
			dm_build_1554 = dm_build_1553.Dm_build_905()
		}

		putData := dm_build_497(dm_build_1548, dm_build_1549, int16(dm_build_1551), dm_build_1553, int32(dm_build_1554))
		_, err := dm_build_1548.dm_build_1350(putData)
		if err != nil {
			return err
		}
	}
	return nil
}

func (dm_build_1556 *dm_build_1310) dm_build_1555() ([]byte, error) {
	var dm_build_1557 error
	if dm_build_1556.dm_build_1318 == nil {
		if dm_build_1556.dm_build_1318, dm_build_1557 = security.NewClientKeyPair(); dm_build_1557 != nil {
			return nil, dm_build_1557
		}
	}
	return security.Bn2Bytes(dm_build_1556.dm_build_1318.GetY(), security.DH_KEY_LENGTH), nil
}

func (dm_build_1559 *dm_build_1310) dm_build_1558() (*security.DhKey, error) {
	var dm_build_1560 error
	if dm_build_1559.dm_build_1318 == nil {
		if dm_build_1559.dm_build_1318, dm_build_1560 = security.NewClientKeyPair(); dm_build_1560 != nil {
			return nil, dm_build_1560
		}
	}
	return dm_build_1559.dm_build_1318, nil
}

func (dm_build_1562 *dm_build_1310) dm_build_1561(dm_build_1563 int, dm_build_1564 []byte, dm_build_1565 string, dm_build_1566 int) (dm_build_1567 error) {
	if dm_build_1563 > 0 && dm_build_1563 < security.MIN_EXTERNAL_CIPHER_ID && dm_build_1564 != nil {
		dm_build_1562.dm_build_1315, dm_build_1567 = security.NewSymmCipher(dm_build_1563, dm_build_1564)
	} else if dm_build_1563 >= security.MIN_EXTERNAL_CIPHER_ID {
		if dm_build_1562.dm_build_1315, dm_build_1567 = security.NewThirdPartCipher(dm_build_1563, dm_build_1564, dm_build_1565, dm_build_1566); dm_build_1567 != nil {
			dm_build_1567 = THIRD_PART_CIPHER_INIT_FAILED.addDetailln(dm_build_1567.Error()).throw()
		}
	}
	return
}

func (dm_build_1569 *dm_build_1310) dm_build_1568(dm_build_1570 bool) (dm_build_1571 error) {
	if dm_build_1569.dm_build_1312, dm_build_1571 = security.NewTLSFromTCP(dm_build_1569.dm_build_1311, dm_build_1569.dm_build_1314.dmConnector.sslCertPath, dm_build_1569.dm_build_1314.dmConnector.sslKeyPath, dm_build_1569.dm_build_1314.dmConnector.user); dm_build_1571 != nil {
		return
	}
	if !dm_build_1570 {
		dm_build_1569.dm_build_1312 = nil
	}
	return
}

func (dm_build_1573 *dm_build_1310) dm_build_1572(dm_build_1574 dm_build_126) bool {
	return dm_build_1574.dm_build_141() != Dm_build_33 && dm_build_1573.dm_build_1314.sslEncrypt == 1
}
